﻿using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;

namespace MoLingsArmory.Content.Items.Weapons.Ranged
{
    public class SuperStarShark : ModItem
    {
        public override void SetDefaults()
        {
            Item.useAmmo = AmmoID.FallenStar;
            Item.useStyle = ItemUseStyleID.Shoot;
            Item.autoReuse = true;
            Item.useAnimation = 7;
            Item.useTime = 7;
            Item.width = 50;
            Item.height = 18;
            Item.shoot = ProjectileID.PurificationPowder;
            Item.UseSound = SoundID.Item9;
            Item.damage = 60;
            Item.shootSpeed = 10f;
            Item.noMelee = true;
            Item.value = Item.buyPrice(gold: 6);
            Item.rare = ItemRarityID.Yellow;
            Item.knockBack = 1f;
            Item.DamageType = DamageClass.Ranged;
        }
        public override bool CanConsumeAmmo(Item ammo, Player player)
        {
            return Main.rand.NextFloat() >= .25f;
        }
        public override Vector2? HoldoutOffset()
        {
            return new Vector2(-6, 0);
        }
        public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
        {
            Vector2 offset = velocity.SafeNormalize(Vector2.UnitX) * 60f;
            Vector2 newPosition = position + offset;
            Projectile.NewProjectile(source, newPosition, velocity, ProjectileID.SuperStar, damage, knockback, player.whoAmI);
            return false;
        }
        public override void AddRecipes()
        {
            Recipe recipe = CreateRecipe();
            recipe.AddIngredient(ItemID.SuperStarCannon, 1);
            recipe.AddIngredient(ItemID.Megashark, 1);
            recipe.AddTile(TileID.MythrilAnvil);
            recipe.Register();
        }
    }
}